#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
	int n, h[20], w[20], r[20], l[20], k[20], a, hans;
	int i, j;

	memset(r, 0, sizeof(r));
	memset(l, 0, sizeof(l));

	scanf("%d", &n);
	for (i=0; i<n; i++) {
		scanf("%d %d", &w[i], &h[i]);
	}
	scanf("%d", &a);

	for (i=0; i<n; i++) {
		for (j=i; j<n-1; j++) {
			if (h[j+1] < h[i]) {
				r[i] += w[j+1];
			} else {
				break;
			}
		}
	}

	for (i=0; i<n; i++) {
		for (j=i; j>=1; j--) {
			if (h[j-1] < h[i]) {
				l[i] += w[j-1];
			} else {
				break;
			}
		}
	}

	for (i=0; i<n; i++) {
		k[i] = r[i] + l[i] + w[i];
	}

	for (i=0; i<n; i++) {
		if (k[i] > a) {
			hans = h[i];
			break;
		}
	}

	for (; i<n; i++) {
		if (k[i] > a && h[i] < hans) {
			hans = h[i];
		}
	}

	printf("%d\n", hans + a);

	return 0;
}
